package com.yonyougov.devops.cruxcisupport.server;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.yonyougov.devops.cruxcisupport.server.dto.ExecuteCmdCommandDto;
import com.yonyougov.devops.cruxcisupport.server.dto.SearchDto;
import com.yonyougov.devops.cruxcisupport.server.dto.ServerPageLikeDto;
import com.yonyougov.devops.cruxcisupport.server.vo.*;
import com.yonyougov.devops.fwc.core.entity.Pagination;
import com.yonyougov.devops.fwc.core.service.BaseService;

import java.math.BigInteger;
import java.util.List;

/**
 * t_server服务
 */
public interface ServerService extends BaseService<ServerEntity, BigInteger> {

    Pagination<ServerPageLikeRespVoParams> findAllByParamsLike(ServerPageLikeDto serverPageLikeReqVoParams) throws Exception;

    int countByLikeServer(ServerPageLikeDto serverPageLikeReqVoParams);

    String dialingTest(ServerEntity serverEntity);

    Pagination<NoLinkServerRespVo> findNoLinkServerByUserId(NoLinkServerDto noLinkServerDto);

    List<NoLinkServerRespVo> findNoLinkServerByEnvId(EnvNoLinkServerPageParams pageParams);

    int findNoLinkServerByEnvIdCount(EnvNoLinkServerPageParams pageParams);

    void batchUpdateServerStatus(List<ServerStatusVo> statusVos);

    /**
     * 执行cmd命令
     *
     * @param executeCmdCommandDto com.yonyougov.devops.cruxcisupport.server.dto.ExecuteCmdCommandDto
     * @return 执行结果
     */
    ExecuteCmdCommandVo executeCmdCommand(ExecuteCmdCommandDto executeCmdCommandDto) throws Exception;

    /**
     * 注册主机
     *
     * @param ip
     * @param hostname
     * @param port
     * @param remark
     */
    void registr(String ip, String hostname, String port, String remark) throws JsonProcessingException;

    /**
     * 刷新服务器状态
     * @param id t_server表id
     */
    void refreshServerStatus(BigInteger id);

    Pagination<ServerSearchVo> search(SearchDto searchDto);
}
